package com.example.demo3.Controller;


import com.example.demo3.Pojo.User;
import com.example.demo3.Service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;


    @GetMapping ("findAll")
    public List<User> findAll(){
        return userService.findAll();
    }

    @RequestMapping("add")
    public String add(@RequestBody User user){
        userService.add(user);
        return "添加成功";
    }
    @RequestMapping("edit")
    public void edit(@RequestBody User user){
        userService.edit(user);
    }
    @RequestMapping("findById")
    public User findById(Integer id){
        return userService.findById(id);
    }
    @RequestMapping("del")
    public void del(Integer id){
        userService.del(id);
    }

}














